package com.bh.web.controller.order;

import com.bh.common.core.controller.BaseController;
import com.bh.common.core.domain.AjaxResult;
import com.bh.common.core.page.TableDataInfo;
import com.bh.order.domain.JcOrderBack;
import com.bh.order.domain.JcOrderBackImagesVo;
import com.bh.order.service.IJcOrderBackService;
import com.bh.order.vo.JcBackOrderVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 运单回单Controller
 * 
 * @author slx
 * @date 2023-12-14
 */
@RestController
@RequestMapping("/order/orderBack")
public class JcOrderBackController extends BaseController
{
    @Autowired
    private IJcOrderBackService jcOrderBackService;

    /**
     * 查询运单回单列表
     */
    @ApiOperation("查询运单回单列表")
    @PreAuthorize("@ss.hasPermi('order:orderBack:list')")
    @GetMapping("/list")
    public TableDataInfo list(JcOrderBack jcOrderBack)
    {
        startPage();
        List<JcOrderBack> list = jcOrderBackService.selectJcOrderBackList(jcOrderBack);
        return getDataTable(list);
    }


    /**
     * 查询运单回单列表
     */
    @ApiOperation("查询运单回单列表")
    @PreAuthorize("@ss.hasPermi('order:orderBack:list')")
    @GetMapping("/orderList")
    public TableDataInfo orderList(JcBackOrderVO backOrderVO)
    {
        startPage();
        backOrderVO.setJcOrganizationId(getOrgId());
        List<JcBackOrderVO> list = jcOrderBackService.selectJcBackOrderList(backOrderVO);
        return getDataTable(list);
    }

    /**
     * 回单接收
     * @param ids
     * @return
     */
    @PreAuthorize("@ss.hasPermi('order:orderBack:edit')")
    @PostMapping(value = "/receive/{ids}")
    public AjaxResult receive(@PathVariable Long[] ids) {
        return toAjax(jcOrderBackService.receive(ids));
    }

    /**
     * 提交回单
     * @param ids
     * @return
     */
    @PreAuthorize("@ss.hasPermi('order:orderBack:edit')")
    @PostMapping(value = "/submit/{ids}")
    public AjaxResult submit(@PathVariable Long[] ids) {
        return toAjax(jcOrderBackService.submit(ids));
    }

    /**
     * 上传回单
     * @param orderBackImages
     * @return
     */
    @PreAuthorize("@ss.hasPermi('order:orderBack:edit')")
    @PostMapping(value = "/uploadOrderBackImage")
    public AjaxResult uploadOrderBackImage(@RequestBody JcOrderBackImagesVo orderBackImages) {
        return toAjax(jcOrderBackService.uploadBackImage(orderBackImages));
    }

    /**
     * 获取运单回单详细信息
     */
    @ApiOperation("获取运单回单详细信息")
    @PreAuthorize("@ss.hasPermi('order:orderBack:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jcOrderBackService.selectJcOrderBackById(id));
    }
}
